package com.cn.scenario.util.test;

import cn.hutool.core.lang.UUID;
import com.google.common.base.Charsets;
import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

/**
 * @Author Boolean
 * @Date 2022/12/26 19:05
 * @Version 1.0
 */
public class GuavaBloomFilterDemo {

    public static void main(String[] args) {
        //后边两个参数：预计包含的数据量，和允许的误差值
        BloomFilter<String> bloomFilter = BloomFilter.create(Funnels.stringFunnel(Charsets.UTF_8), 100000, 0.01);
        for (int i = 0; i < 100000; i++) {
            bloomFilter.put(UUID.randomUUID().toString().replace("-", "").toLowerCase());
        }
        System.out.println("111");
       // System.out.println(bloomFilter.mightContain(1));
        //bloomFilter.writeTo();
    }
}
